package com.yongqi.duocai.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 1.描述（@desc）：
 * 2.作者（@author）：夏亮辉
 * 3.日期（@date）：2021年06月19  12:55
 * 4.版本（@version）：1.0.0
 * 5.版权：
 */

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.yongqi.duocai.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("多彩贵州线上订购小程序")
                .description("用于为多彩贵州线上订购小程序，提供一套 API 说明")
                .contact(new Contact("多彩贵州小程序", "http://chain.yqhuixuan.com", "xuetang9@mail.com"))
                .version("2.0")
                .build();
    }

}
